home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 364 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.4 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Is a diagnostic required?
  5. Date: 23 Feb 1996 01:00:46 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb22180046@qcd.lanl.gov>
  8. References: <danpop.824999740@rscernix>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: danpop@mail.cern.ch's message of 22 Feb 96 14:35:40 GMT
  13.  
  14. Path: newshost.lanl.gov!ferrari.mst6.lanl.gov!tesuque.cs.sandia.gov!sloth.swcp.com!ns2.mainstreet.net!bug.rahul.net!rahul.net!a2i!genmagic!sgigate.sgi.com!wrdis02.robins.af.mil!rcp6.elan.af.mil!rscernix!danpop
  15. From: danpop@mail.cern.ch (Dan Pop)
  16. Newsgroups: comp.std.c
  17. Subject: Is a diagnostic required?
  18. Date: 22 Feb 96 14:35:40 GMT
  19. Organization: CERN European Lab for Particle Physics
  20. Lines: 27
  21. Message-ID: <danpop.824999740@rscernix>
  22. NNTP-Posting-Host: ues5.cern.ch
  23. X-Newsreader: NN version 6.5.0 #7 (NOV)
  24.  
  25. In article <danpop.824999740@rscernix>
  26. danpop@mail.cern.ch (Dan Pop) writes:
  27.  
  28. DP: Hi,
  29. DP: 
  30. DP: Does the following code require a diagnostic?
  31. DP: 
  32. DP:     foo()
  33. DP:     {
  34. DP:     }
  35. DP: 
  36. DP:     main()
  37. DP:     {
  38. DP:     foo(3);
  39. DP:     }
  40. DP: 
  41.  
  42. No.
  43.  
  44. DP: I was always convinced that there is no difference between foo() and
  45. DP: foo(void) in the _definition_ of the function foo and that 'void' as the
  46. DP: argument list of a function was introduced for function declarations,
  47. DP: because an empty argument list in a function declaration had to be
  48. DP: treated as in K&R C.  Yet, all the compilers I tried accepted this code
  49. DP: without complaint and complained when 'void' was introduced in the
  50. DP: definition of foo.
  51.  
  52. 6.5.4.3 shows 
  53.  
  54. D (parameter-type-list)
  55. or
  56. D (identifier-list_opt)
  57.  
  58. Note that the parameter-type-list is not optional.
  59.  
  60. Now, there is a special case for empty identifier-list_opt in
  61. definition of a function for the purposes of determining type
  62. compatibililty. Thus an `int foo(int)' declaration in your above
  63. program would lead to a diagnostic being required.
  64.  
  65. 6.7.1 clarifies that only functions defined with parameter-type-lists
  66. acquire a prototype. Of course, `only' means no other clause leads to
  67. a prototyped function: which is ridiculous because this clause is
  68. talking about function definitions only. However, the usage in 6.5.4.3
  69. `If one type has a parameter type list and the other type is specified
  70. by a function definition that contains a (possibly empty) identifier
  71. list, both shall agree in the number of parameters and the type of
  72. each prototype parameter shall be compatible with the type that
  73. results from the application of the default argument promotions to the
  74. type of the corresponding identifier' seems to argue that when a
  75. declaration specifies a parameter-type-list, it is a prototype. Why
  76. didn't the standard make this explicit anyway by a statement in
  77. 6.5.4.3? Or does it actually mention it somewhere else?
  78.  
  79. In any case, the intent is clear: and as 6.3.2.2 constraint applies
  80. only to prototyped function, no diagnostic is required.
  81.  
  82. Cheers
  83. Tanmoy
  84. --
  85. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  86. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  87. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  88. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  89. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  90. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  91.